package com.cq.hd.admin.controller;

import com.cq.hd.admin.annotation.RequiresPermissionsDesc;
import com.cq.hd.common.enums.biz.PayStateEnum;
import com.cq.hd.common.enums.biz.PayTypeEnum;
import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.member.api.TbMemberFeeBillApi;
import com.cq.hd.member.api.dto.AdminMemberFeeBillPageDto;
import com.cq.hd.member.api.vo.AdminMemberFeeBillPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Arrays;

@Api(tags = "会员续费记录相关接口")
@Slf4j
@RestController
@RequestMapping("/memberFeeBill")
public class TbMemberFeeBillController extends BaseController {

    @Autowired
    private TbMemberFeeBillApi memberFeeBillApi;

    @ApiOperation(value = "查询累计成交金额")
    @ApiResponse(response = BigDecimal.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("finance:memberFeeBill:getTotalAmt")
    @RequiresPermissionsDesc(menu = {"财务管理", "会员续费记录"}, button = "查询累计成交金额")
    @GetMapping("/getTotalAmt")
    public Result<BigDecimal> getTotalAmt() {
        return memberFeeBillApi.getTotalAmt();
    }

    @ApiOperation(value = "会员续费记录列表")
    @ApiResponse(response = AdminMemberFeeBillPageVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("finance:memberFeeBill:list")
    @RequiresPermissionsDesc(menu = {"财务管理", "会员续费记录"}, button = "查询")
    @GetMapping("/page")
    public Result<Page<AdminMemberFeeBillPageVo>> pageAdminMemberFeeBill(AdminMemberFeeBillPageDto adminMemberFeeBillPageDto) {
        adminMemberFeeBillPageDto.setPayTypes(Arrays.asList(PayTypeEnum.WX.getValue(), PayTypeEnum.BANK.getValue()));
        adminMemberFeeBillPageDto.setPayState(PayStateEnum.SUCCESS.getValue());
        return memberFeeBillApi.pageAdminMemberFeeBill(adminMemberFeeBillPageDto);
    }

}
